{% extends "base.html" %}
{% block header_js %}
    <script type="text/javascript">
$(document).ready(function() {
    $(".tpl").change(
        function() {
            var selectTpl = $("input[name='tpl']:checked").val();
            $.get("/report/ajax_get_tpl/?tpl="+ selectTpl, function(data){
                $("#tpl_contain").html(data);
            });
        });
    $("#pid").change(
    function(){
        var id = $('#pid').val();
        var tpl = $("input[name='tpl']:checked").val();
        if(id == '--') {
            alert("请选择产品线");
            return false;
        }
        if(!tpl) return;
        $.get('/report/ajax_get_monitor', {"pid": id,"tpl":tpl}, function(data){
            $("#product_monitor").html(data);
        });

      });

    });
</script>


{% endblock %}
<body>
{% block header %}
{% include "report-menu.html" %}
{% endblock %}

{% block content %}
<div class="wrap">
	{% include "tree.html" %}
    <div class="wrap_left right">
	    <div class="shenqing1">
	    	<h5 style="float:left;width:96%;margin-bottom:10px;">创建报表</h5>
		</div>
        <div class="caozuo_add">
        	<form action="/report/edit/" method="post">
            <div class="box">
            <h2>修改报表</h2>
            <div class="row">
                <label class="">报表ID:</label>
                <input type="text" name="id" class="word_in boxinput" value={{report.id}} />
            </div>

            <div class="row">
                <label class="">报表名称:</label>
                <input type="text" name="name" class="word_in boxinput" value={{report.name}} />
            </div>

            <div class="row">
                <label class="">发送周期:</label>
                <div>
          	        每日 <input name="freq" type="radio" value="1" checked />
		            每周 <input name="freq" type="radio" value="7" />
		            每月 <input name="freq" type="radio" value="30" />
                </div>
            </div>

            <div class="row">
                <label class="">模版选择:</label>
                <div>
            	{% for t in tpl %}
                    {% if report.tpl == t%}
						{{ t }}&nbsp;&nbsp;&nbsp;<input class="tpl" name="tpl" type="radio" value="{{t}}" checked/>&nbsp;&nbsp;
                    {% else %}
						{{ t }}&nbsp;&nbsp;&nbsp;<input class="tpl" name="tpl" type="radio" value="{{t}}"/>&nbsp;&nbsp;
                    {% endif %}
				{% endfor %}
                </div>
            </div>
          
            <div class="row" id="tpl_contain"></div>

            <div class="row">
                <label class="">接受小组:</label>
                <div>
                    <select name="group" class="sel">
		                {% for g in group %}
							<option value="{{ g.id }}">{{ g.name }}</option>
						{% endfor %}
					</select>
                </div>
            </div>
            <div class="row">
                <label class="">接受个人:</label>
                <div>
		            {% for u in user %}
            <input class="fuxuan" type="checkbox" value="{{u.id}}" name="user"/>{{u.username}}
					{% endfor %}
					</select>
                </div>
            </div>

            <div class="row">
                <label class="">产品线:</label>
                <div>
                    <select id="pid" name="pid" class="sel">
						<option >--</option>
		                {% for p in product %}
						<option value="{{ p.id }}">{{ p.name }}</option>
						{% endfor %}
					</select>
                </div>
            </div>
            <div class="row" id="product_monitor"></div>
            
            <div class="row">
                <label class="">统计方式:</label>
                <div>
	                <select name="statistics" class="sel">
                            {%for st in statistics%}
							<option value="{{st.0}}">{{st.1}}</option>
                            {% endfor %}
					</select>
                </div>
            </div>

        </div>
	    <input type="submit" class="tijiao_big" value="&nbsp;&nbsp;提交" />

			</form>
		</div>
    </div>
</div>
{% endblock %}

</body>
</html>
